﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agresso.Interface.Layer.Gateway;
using System.Data.SqlClient;
using Agresso.Interface.Layer.SQL;
using System.Data;

namespace Agresso.Interface.Layer.Service
{
    public class AstwarehouseService
    {
        DataBaseConnectivity m_dataBaseConectivity;
        public AstwarehouseService()
        {
            m_dataBaseConectivity = new DataBaseConnectivity();
        }
        public bool IsRegisteredWarehouse(string code)
        {
            bool result = false;
            try
            {
                m_dataBaseConectivity.AgrTempConnectionSQLConnection.Open();
                SqlCommand cmd = new SqlCommand(AgressoSQL.GetWarehouseCount(), m_dataBaseConectivity.AgrTempConnectionSQLConnection);
                cmd.Parameters.Add("@dim_5", SqlDbType.NVarChar).Value = code.Trim();
                LogService.WriteLogExecuteSQLCommand(cmd);
                int p = Convert.ToInt16(cmd.ExecuteScalar());
                result = p > 0;
                return result;
            }
            catch (Exception x)
            {
                LogService.WriteLogException(x);
                throw x;
            }
            finally
            {
                m_dataBaseConectivity.AgrTempConnectionSQLConnection.Close();
            }
        }
    }
}
